package com.yonyou.sto.modules.ims.service;

import com.yonyou.sto.common.api.CommonResult;
import com.yonyou.sto.modules.ims.dto.CallbackInvoiceParam;
import com.yonyou.sto.modules.ims.dto.ImsInvoiceParam;
import com.yonyou.sto.modules.ims.model.ImsInvoice;
import com.baomidou.mybatisplus.extension.service.IService;
import io.swagger.models.auth.In;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import javax.xml.crypto.Data;
import java.security.Principal;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务类
 * </p>
 *
 * @author aegon
 * @since 2020-09-15
 */
public interface ImsInvoiceService extends IService<ImsInvoice> {

    /**
     * 根据收款单编码查询
     * @param billSn
     * @return
     */
    ImsInvoice getOneByBillSn(String billSn);

    /**
     * 添加单据
     * @param imsInvoiceParam
     * @return
     */
    CommonResult create(ImsInvoiceParam imsInvoiceParam);

    /**
     * 退回单据
     * @param billSn
     * @return
     */
    CommonResult revoke(String billSn);

    /**
     * 更新单据
     * @param param
     * @return
     */
    CommonResult updateBill(ImsInvoiceParam param);

    /**
     * 分页查询数据
     * @param pageSize
     * @param pageNum
     * @param billSn
     * @param sellerName
     * @param buyerName
     * @param statusList
     * @param startTime
     * @param endTime
     * @return
     */
    CommonResult<Map<String, Object>> list(String username, Integer pageSize, Integer pageNum, String billSerial, String billSn, String billNo, String billCode, String sellerName, String buyerName, List<Integer> statusList, String startTime, String endTime, String djlx,String billType,String applyname,String ncName);

    /**
     * 分页查询待开票数据
     * @param pageSize
     * @param pageNum
     * @param billSn
     * @param sellerName
     * @param buyerName
     * @param djlx 单据类型：fp->销售发票 ,  ->应收单, ->内部交易结算单
     * @param startTime
     * @param endTime
     * @return
     */
    CommonResult<Map<String, Object>> listNotice(String username, Integer pageSize, Integer pageNum, String billSn, String sellerName, String buyerName, String djlx, String startTime, String endTime);

    /**
     * 分页查询开票申请数据
     * @param pageSize
     * @param pageNum
     * @param billSn
     * @param sellerName
     * @param buyerName
     * @param djlx
     * @param status
     * @param startTime
     * @param endTime
     * @return
     */
    CommonResult<Map<String, Object>> listApply(String username, Integer pageSize, Integer pageNum, String billSn, String sellerName, String buyerName,String djlx,Integer status, String startTime, String endTime);


    /**
     * 批量删除单据
     *
     * @param ids@return
     */
    CommonResult deleteInvoice(List<String> ids);

    /**
     * 批量退回单据
     *
     * @param ids@return
     */
    CommonResult returnInvoice(List<String> ids);

    boolean updateStatusBySn(int code, List<String> billSn);

    /**
     * 查询单据明细和退回记录
     * @param id
     * @return
     */
    CommonResult invoiceInfo(String id);
    /**
     * 合并
     *
     * @param ids@return
     */
    CommonResult merge(List<String> ids);


    boolean updateStatusApply(String id, String name, String code, int billType, double applyje,int status,int contain);

    /**
     * 批量作废发票
     * @param ids   发票id
     * @return
     */
    CommonResult<String> cancel(List<String> ids, Principal principal);

    String updateBySerial(CallbackInvoiceParam param);

    CommonResult<Map<String, Object>> mergeList(List<String> ids);

    CommonResult<Map<String, Object>> applyList(String name,List<String> ids);

    XSSFWorkbook downLoadPageNumInvoice(String username, Integer pageSize, Integer pageNum, String billSerial, String billSn, String billNo, String billCode, String sellerName, String buyerName, Integer statusList, String startTime, String endTime, String djlx);
}
